<!DOCTYPE html>
<html lang="zh-CN">
<head>
    {% load static %}
{#    <meta charset="utf-8">#}
{#    <meta http-equiv="X-UA-Compatible" content="IE=edge">#}
{#    <meta name="viewport" content="width=device-width, initial-scale=1">#}
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>登录</title>
    <link rel="stylesheet" href="{% static 'js/login/css/style.css' %}">
</head>
<body>
<div class="login-container">
    <h1>登录系统</h1>
    <div class="connect">
        <p style="left: 0%;">Link the world. Share to world.</p>
    </div>
{#    <form action="" method="post" id="loginForm" novalidate="novalidate">#}
        {% csrf_token %}
        <div>
            <input type="text" name="email" class="email" placeholder="邮箱" autocomplete="off"
                   id="emailInput">
        </div>
        <div>
            <input type="password" name="password" class="password" placeholder="密码" oncontextmenu="return false"
                   onpaste="return false" id="passwdInput">
        </div>
        <p> {{ error }} </p>
        <button id="btn_submit" type="submit">登 陆</button>
{#    </form>#}
    <a href="register.html">
        <button type="button" class="register-tis">还没有账号？</button>
    </a>
</div>
<script src="{% static 'bower_components/jquery/dist/jquery.js' %}"></script>
<script src="{% static 'js/login/js/supersized.3.2.7.min.js' %}"></script>
<script src="{% static 'js/login/js/supersized-init.js' %}"></script>
<script src="{% static 'js/cookie.js' %}"></script>
<script>
    $("#btn_submit").on("click", function () {
        console.log("aaaaaaaaaaaaaaaaaaa")
        console.log("aaa=", $.cookie('csrftoken'))
        let param = new FormData()
        let csrf = $('input[name=csrfmiddlewaretoken]').val()
        console.log($("#nameInput").val())
        console.log($("#passwdInput").val())
        console.log(csrf)
        $.ajax({
            url:{% url 'login' %},
            type: "post",
            data: {
                email: $("#emailInput").val(),
                password:$("#passwdInput").val(),
                {#csrfmiddlewaretoken: csrf,#}
                },
            headers:{'X-CSRFtoken':$.cookie('csrftoken')},
            success: function (result) {
                console.log("result==")
                console.log(result)
                console.log(typeof result)
                location.href={% url 'userList' %}
            }
        })
    })
</script>

</body>
</html>